package logic

import (
	"context"
	"github.com/zeromicro/go-zero/core/logx"
	"zero-demo-rpc/mall/MakeProduct/api/internal/svc"
	"zero-demo-rpc/mall/MakeProduct/api/internal/types"
)

type MakeProductLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewMakeProductLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MakeProductLogic {
	return &MakeProductLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *MakeProductLogic) MakeProduct(req *types.MakeReq) (resp *types.MakeReply, err error) {
	// todo: add your logic here and delete this line

	//笑死啥都不用写，调用就报错了

	/*
		fmt.Println("开始上传：")
		fmt.Println("用户名：" + string(req.UserName))

		err1 := os.Mkdir("C:/server/"+req.UserName, 0777)
		if err1 != nil {
			fmt.Println("创建文件夹失败！", err)
		}
		fmt.Println("创建用户文件夹")

			reader := bytes.NewReader(req.Img)

			// read the data from reader
			// buf := make([]byte, len(req.Img))
			// if _, err := reader.Read(buf); err != nil {
			// 	log.Fatal(err)
			// }

			dst, _ := os.Create("./" + req.UserName + "/" + req.NftName)
			defer dst.Close()
			_, err2 := io.Copy(dst, reader)
			if err2 != nil {
				log.Println("copy file error :", err)
			}
	*/
	return &types.MakeReply{
		Result: "This is a Logic Respose",
	}, err
}
